<?

include_once("./_common.php");

auth_check($auth[$sub_menu], "r");

$sql_common = " from coupon_record ";

$sql = " select count(*) as cnt
         $sql_common ";

$row = sql_fetch($sql);
$total_count = $row[cnt];

$rows = $config[cf_page_rows];
$total_page  = ceil($total_count / $rows);  // 전체 페이지 계산
if (!$page) $page = 1; // 페이지가 없으면 첫 페이지 (1 페이지)
$from_record = ($page - 1) * $rows; // 시작 열을 구함

$sql = " select * 
          $sql_common 
          $sql_search
          $sql_order 
          limit $from_record, $rows ";
$result = sql_query($sql);

$listall = "<a href='$_SERVER[PHP_SELF]'>처음</a>";

$g4[title] = "쿠폰관리";
include_once("./admin.head.php");

$colspan = 8;
?>

<script language="JavaScript">
var list_update_php = "./coupon_list_update.php";
</script>

<table width=100% cellpadding=0 cellspacing=0 border=0 class="board_list" style="text-align: center">
<form name=fboardgrouplist method=post>
<input type=hidden name=sst  value='<?=$sst?>'>
<input type=hidden name=sod  value='<?=$sod?>'>
<input type=hidden name=sfl  value='<?=$sfl?>'>
<input type=hidden name=stx  value='<?=$stx?>'>
<input type=hidden name=page value='<?=$page?>'>
<col width=30/>
<col width=307/>
<col width=80/>
<col width=80/>
<col width=80/>
<tr class='bgcol1 bold col1 ht center'>
    <th><input type=checkbox name=chkall value="1" onclick="check_all(this.form)"></th>
    <!-- <td><?=subject_sort_link("wr_subject")?>쿠폰번호</a></td> -->
    <th>쿠폰이미지</th>
    <th>쿠폰내용</th>
    <th>남은쿠폰</th>
    <th><? if ($is_admin == "super") { echo "<a href='./coupon_form.php?bo_table=coupon'><img src='./img_btn/plus_btn.gif' border=0 title='생성'></a>"; } ?></th>
</tr>

<?
for ($i=0; $row=sql_fetch_array($result); $i++) 
{
    echo "<input type=hidden name=cu_no[$i] value='$row[cu_no]'>";
    echo "<tr class='list$list' onmouseover=\"this.className='mouseover';\" onmouseout=\"this.className='list$list';\" height=27 align=center>";
    echo "<td><input type=checkbox name=chk[] value='$i'></td>";

// 	echo "<td align=center><b>$row[cu_number]</b></a></td>";
	if ($row[cu_img]) {
		$temp_name = explode('||',$row[cu_img]);
		$original_file_name = $temp_name[0];
	}
	echo "<td align=center><img src='./file/coupon/$original_file_name' style='width: 307px;'></img></td>";
    //echo "<td align=center><input type=text class=ed name=cu_content[$i] value='".$row[cu_content]."' size=30></td>";
    $content = conv_subject($row[cu_content], 30, "…");
    
	echo "<td align=center>$row[cu_content]</td>";

    $s_upd = "<a href='./coupon_form.php?bo_table=coupon$qstr&w=u&cu_no=$row[cu_no]'><img src='img_btn/co_btn_modify.gif' border=0 title='수정'></a>";
    
    $s_del = "<a href=\"javascript:del('./coupon_delete.php?$qstr&cu_no=$row[cu_no]');\"><img src='img_btn/co_btn_delete.gif' border=0 title='삭제'></a>";
    
    $s_issue = "<a href='./coupon_issue.php?bo_table=coupon$qstr&cu_no=$row[cu_no]'><img src='img_btn/icon_total.gif' border=0 title='발급'></a>";

//     if ($is_admin == "super")
//         //echo "<td>".get_member_id_select("gr_admin[$i]", 9, $row[gr_admin])."</td>";
//         echo "<td align=center><input type=text class=ed name=cu_limit[$i] value='$row[cu_limit]' maxlength=10 size=5></td>";
//     else
        echo "<td align=center>$row[cu_limit]</td>";
    
    	echo "<td>$s_upd $s_del $s_issue</td>";
    echo "</tr>\n";
} 

if ($i == 0)
    echo "<tr><td align=center height=100 bgcolor=#ffffff>자료가 없습니다.</td></tr>"; 


echo "</table>";

$pagelist = get_paging($config[cf_write_pages], $page, $total_page, "$_SERVER[PHP_SELF]?$qstr&page=");
echo "<table width=100% cellpadding=3 cellspacing=1>";
echo "<tr><td width=70%>";
echo "<input type=button class='btn1' value='선택수정' onclick=\"btn_check(this.form, 'update')\">";
//echo " <input type=button value='선택삭제' onclick=\"btn_check(this.form, 'delete')\">";
echo "</td>";
echo "<td width=30% align=right>$pagelist</td></tr></table>\n";

if ($stx)
    echo "<script>document.fsearch.sfl.value = '$sfl';</script>";
?>
</form>

<?
include_once("../admin.tail.php");
?>
